﻿using Sinergija13.DataModel.Models.Conf;
using Sinergija13.DataModels;
using Sinergija13.DataServices.Store.Conf;
using Sinergija13.WP7App.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media;

namespace Sinergija13.WP7App.ViewModels
{
    public class FloormapViewModel : ViewModel
    {
        private readonly IConfDataStoreLocator confDataStoreLocator; //ctor param

        public FloormapViewModel(
            IConfDataStoreLocator confDataStoreLocator,
            INavigationService navigationService)
            : base(navigationService)
        {
            this.confDataStoreLocator = confDataStoreLocator;
            initialize();
        }

        private void initialize()
        {
            this.IsBeingActivated();
        }

        private int? id;
        private Room room;
        public Room Room
        {
            get
            {
                var id = int.Parse(NavigationService.CurrentSource
                                       .OriginalString.Split('=')[1]);
                if (this.id == null || (this.id != id))
                {
                    this.id = id;
                    room = confDataStoreLocator.GetStore().FindRoom(id);
                }
                return room;
            }
        }

        public override void IsBeingActivated()
        {}

        public Brush Room1Color
        {
            get
            {
                if (Room.Code.Equals("Kristal A"))
                    return new SolidColorBrush(ColorConverter.GetColorFromString("#aaff8c00"));
                else
                    return new SolidColorBrush(ColorConverter.GetColorFromString("#aa00b294"));
            }
        }

        public Brush Room2Color
        {
            get
            {
                if (Room.Code.Equals("Kristal B"))
                    return new SolidColorBrush(ColorConverter.GetColorFromString("#aaff8c00"));
                else
                    return new SolidColorBrush(ColorConverter.GetColorFromString("#aa00b294"));
            }
        }

        public Brush Room3Color
        {
            get
            {
                if (Room.Code.Equals("Kristal C"))
                    return new SolidColorBrush(ColorConverter.GetColorFromString("#aaff8c00"));
                else
                    return new SolidColorBrush(ColorConverter.GetColorFromString("#aa00b294"));
            }
        }

        public Brush Room4Color
        {
            get
            {
                if (Room.Code.Equals("Kopaonik"))
                    return new SolidColorBrush(ColorConverter.GetColorFromString("#aaff8c00"));
                else
                    return new SolidColorBrush(ColorConverter.GetColorFromString("#aa00b294"));
            }
        }

        public Brush Room5Color
        {
            get
            {
                if (Room.Code.Equals("Beograd"))
                    return new SolidColorBrush(ColorConverter.GetColorFromString("#aaff8c00"));
                else
                    return new SolidColorBrush(ColorConverter.GetColorFromString("#aa00b294"));
            }
        }

        public Brush Room6Color
        {
            get
            {
                if (Room.Code.Equals("Budva"))
                    return new SolidColorBrush(ColorConverter.GetColorFromString("#aaff8c00"));
                else
                    return new SolidColorBrush(ColorConverter.GetColorFromString("#aa00b294"));
            }
        }

        public Brush Room7Color
        {
            get
            {
                if (Room.Code.Equals("Ellington's"))
                    return new SolidColorBrush(ColorConverter.GetColorFromString("#aaff8c00"));
                else
                    return new SolidColorBrush(ColorConverter.GetColorFromString("#aa00b294"));
            }
        }
   
    }
}
